home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / xcmd / sprtxtrn.sea / Support Tools eXternals 1.2.5 / card_41128.txt < prev    next >
Text File  |  1990-11-13  |  11KB  |  354 lines

  1. -- card: 41128 from stack: in.5
  2. -- bmap block id: 45332
  3. -- flags: 0000
  4. -- background id: 3858
  5. -- name: SysEnvironment
  6. ----- HyperTalk script -----
  7. on CloseCard
  8.   put empty into cd fld "attribute list"
  9.   set the scroll of cd fld "attribute list" to 0
  10.   pass CloseCard
  11. end CloseCard
  12.  
  13. on HideObjects
  14.   hide cd fld "attribute list"
  15.   hide cd btn "try it!"
  16. end HideObjects
  17.  
  18. on ShowObjects
  19.   show cd fld "attribute list"
  20.   show cd btn "try it!"
  21. end ShowObjects
  22.  
  23.  
  24. -- part 1 (button)
  25. -- low flags: 00
  26. -- high flags: A002
  27. -- rect: left=82 top=299 right=333 bottom=175
  28. -- title width / last selected line: 0
  29. -- icon id / first selected line: 0 / 0
  30. -- text alignment: 1
  31. -- font id: 0
  32. -- text size: 12
  33. -- style flags: 8192
  34. -- line height: 16
  35. -- part name: Try it!
  36. ----- HyperTalk script -----
  37. on mouseUp
  38.   global errGlobal
  39.   put SysEnvironment("noDialog:errGlobal") into attribs
  40.   if errGlobal Γëá empty then
  41.     answer "Error:" && errGlobal
  42.     put empty into errGlobal
  43.   else
  44.     put attribs into cd fld "attribute list"
  45.   end if
  46. end mouseUp
  47.  
  48.  
  49.  
  50. -- part 2 (field)
  51. -- low flags: 00
  52. -- high flags: 0007
  53. -- rect: left=11 top=117 right=288 bottom=249
  54. -- title width / last selected line: 0
  55. -- icon id / first selected line: 0 / 0
  56. -- text alignment: 0
  57. -- font id: 4
  58. -- text size: 9
  59. -- style flags: 0
  60. -- line height: 12
  61. -- part name: attribute list
  62.  
  63.  
  64. -- part contents for background part 38
  65. ----- text -----
  66. 44/50
  67.  
  68. -- part contents for background part 20
  69. ----- text -----
  70. This XFCN returns the same information that the toolbox call SysEnvirons returns.  The only difference is that we translate the information for you.  This XFCN can not return the proper information for CPU's, keyboards or processors added since it was last updated.  In this case it will say "unknown CPU xx" where xx is the number constant returned from the SysEnvirons call .
  71.  
  72.      Calling Syntax: SysEnvironment(┬½"noDialog:errGlobal"┬╗)
  73.  
  74.  
  75. -- part contents for background part 42
  76. ----- text -----
  77. unit sysEnv;
  78. { an XFCN which checks to see which type of Macintosh is running and what it's current }
  79. {environment is.  returns a string of information separated by commas.  uses SysEnviorns }
  80. {toolbox call, refer to IM V for more details }
  81. {  values returned are: }
  82. { SysEnviorns version }
  83. { machine type (ie. Mac IIxx}
  84. { system version (ie. 9.0.1) }
  85. { processor (ie. 68040)}
  86. { has floating point (FPU) }
  87. { has color QuickDraw }
  88. { keyboard type }
  89. { AppleTalk Driver version }
  90. { system folder reference number }
  91. {}
  92. {  brought to you by:  Anup Murarka      Eric Carlson    }
  93. {            ALINK:  SKEPTIC      ALINK:  cyNic  }
  94. {                  CIS:  76004,3356    }
  95. {}
  96. {        We are part of the Support Tools Development Group,  }
  97. {        Apple Computer, Inc.   }
  98. {}
  99. {        please DO NOT contack Mac DTS for support of this code!  }
  100. {}
  101. {        please DO contact the authors for support of this code!  }
  102. {}
  103. {        Send comments, bug reports, requests to any of the above  }
  104. {        E-mail addresses or to:}
  105. {}
  106. {              (one of us)          }
  107. {              Apple Computer, Inc.     }
  108. {              900 E. Hamilton, Ave.    }
  109. {              Campbell, CA   95008    }
  110. {              M/S 72-L          }
  111. {}
  112. {  Copyright:  ┬⌐ 1989, 1990 by Apple Computer, Inc., all rights reserved.  }
  113. {}
  114. { written by Eric Carlson                    }
  115. { AppleLink:  cyNic                        }
  116. { modification history                      }
  117. {   ----------------------------------------------------------------}
  118. {    11/12/90     ec    corrected IIfx number (thought it was 12, is 11) reved to 1.3.1  }
  119. {    10/8/90      ec    added code for LC, Classic, and IIsi. reved to 1.3  }
  120. {    6/1/90      ec    recompiled with new library routined, added misc comments  }
  121. {    3/20/90      ec    added code for IIfx, changed version to 1.2    }
  122. {    9/19/89      ec    added codes for IIci & portable, changed version to 1.1  }
  123. {    7/28/89      ec    first written    }
  124. {}
  125. interface
  126.   uses
  127.     HyperXCmd;
  128.  
  129.   procedure main (paramPtr: XCmdPtr);
  130.  
  131. implementation
  132.  
  133.   procedure reportToUser (paramPtr: XCmdPtr;
  134.                   msgStr: str255);
  135. {}
  136. { report something back to the user.  }
  137. { the last parameter (optional) to an external may contain }
  138.  { "noDialog" or "noDialog:GlobalName".  GlobalName is the name }
  139.  { of a HyperTalk global variable into which error messages will be }
  140.  { placed.  we've decided to use this approach to avoid confusing }
  141. { an error message with a valid result being returned from an XFCN. }
  142. {}
  143.     var
  144.       tempStr: str255;
  145.   begin
  146. {check the last param to see if the user requested that}
  147. { we suppress the error dialog }
  148.     ZeroToPas(paramPtr, paramPtr^.params[paramPtr^.paramCount]^, tempStr);
  149.     UprString(tempStr, true);
  150.     if pos('NODIALOG', tempStr) = 0 then
  151. { no special error handling specified, throw up a dialog and return the error message }
  152.       begin
  153.         SendCardMessage(paramPtr, concat('answer "', msgStr, '"'));
  154.         paramPtr^.returnValue := PasToZero(paramPtr, msgStr);
  155.       end
  156.     else if (pos(':', tempStr) > 0) then
  157. { requested global AND noDialog so we fill in the global and return empty }
  158.       begin
  159.         tempStr := copy(tempStr, pos(':', tempStr) + 1, length(tempStr));
  160. { get the name of the HC global  to fill }
  161.         SetGlobal(paramPtr, tempStr, PasToZero(paramPtr, msgStr));
  162. { and fill it }
  163.         paramPtr^.returnValue := PasToZero(paramPtr, '');{ return empty }
  164.       end
  165.     else
  166. { requested noDialog only so we return the error condition as the result }
  167.       paramPtr^.returnValue := PasToZero(paramPtr, msgStr);
  168.   end;{ procedure }
  169.  
  170.   function AskedForHelp (paramPtr: XCmdPtr;
  171.                   syntaxMsg: Str255;
  172.                   copyrightMsg: Str255): boolean;
  173. {check to see if the user sent a '?' or a '!' as }
  174. { the only parameter. if so we will respond with }
  175. { the calling syntax or the copyright/version info }
  176. { for this external }
  177. {}
  178.     var
  179.       firstStr: str255;
  180.   begin
  181.     askedForHelp := false;
  182.     if paramPtr^.paramCount = 1 then
  183.       begin
  184.         ZeroToPas(paramPtr, paramPtr^.params[1]^, firstStr);
  185. { what is the first param? }
  186.         if firstStr = '?' then
  187.           begin
  188.             reportToUser(paramPtr, syntaxMsg);
  189.             askedForHelp := true
  190.           end{ asked for help }
  191.         else if firstStr = '!' then
  192.           begin
  193.             reportToUser(paramPtr, copyRightMsg);
  194.             askedForHelp := true
  195.           end;{ asked for copyright info }
  196.       end;{ one parameter passed }
  197.   end;{ function }
  198.  
  199.   function NumberToHex (paramPtr: XCmdPtr;
  200.                   num: LONGINT;
  201.                   nDigits: INTEGER): Str255;
  202. { why, oh why did dan write this one as a procedure??? }
  203.     var
  204.       tempStr: str255;
  205.   begin
  206.     NumToHex(paramPtr, num, nDigits, tempStr);
  207.     NumberToHex := tempStr;
  208.   end;
  209.  
  210.   function NumberToString (paramPtr: XCmdPtr;
  211.                   num: LONGINT): Str255;
  212. { use the toolbox call rather than HC's }
  213.     var
  214.       tempStr: str255;
  215.   begin
  216.     NumToString(num, tempStr);
  217.     NumberToString := tempStr;
  218.   end;
  219.  
  220.   procedure sysEnv (paramPtr: XCmdPtr);
  221.     var
  222.       theSysRec: SysEnvRec;
  223.       err, tempInt: Integer;
  224.       tempStr, theResult: Str255;
  225.  
  226.   begin
  227.     if askedForHelp(paramPtr, 'sysEnvironment([ΓÇ£noDialogΓÇ¥:errorGlobal])', ' v1.3.1 ┬⌐ 1989, 1990 Apple Computer, Inc., by Eric Carlson') then
  228.       exit(sysEnv);{ exit just asking for help }
  229.  
  230.     err := SysEnvirons(1, theSysRec);{ make our call }
  231.     if err <> 0 then
  232.       begin
  233.         ReportToUser(paramPtr, 'Problem calling SysEnvironment.');
  234.         Exit(sysEnv);
  235.       end;
  236.  
  237.     case theSysRec.machineType of{ what machine are we on? }
  238.       -1: 
  239.         tempstr := 'Macintosh with 64K ROM,';
  240.       -2: 
  241.         tempstr := 'Macintosh XL,';
  242.       0: 
  243.         tempstr := 'unknown Macintosh,';
  244.       1: 
  245.         tempstr := 'Macintosh 512KE,';
  246.       2: 
  247.         tempstr := 'Macintosh Plus,';
  248.       3: 
  249.         tempstr := 'Macintosh SE,';
  250.       4: 
  251.         tempstr := 'Macintosh II,';
  252.       5: 
  253.         tempstr := 'Macintosh IIx,';
  254.       6: 
  255.         tempstr := 'Macintosh IIcx,';
  256.       7: 
  257.         tempstr := 'Macintosh SE/30,';
  258.       8: 
  259.         tempstr := 'Macintosh Portable,';
  260.       9: 
  261.         tempstr := 'Macintosh IIci,';
  262.       11: 
  263.         tempstr := 'Macintosh IIfx,';
  264.       15: 
  265.         tempstr := 'Macintosh Classic,';
  266.       16: 
  267.         tempstr := 'Macintosh IIci,';
  268.       17: 
  269.         tempstr := 'Macintosh LC,';
  270.       otherwise
  271.         tempstr := concat('unknown machine #', NumberToString(paramPtr, theSysRec.machineType), ', ');
  272.     end;
  273.     theResult := tempstr;
  274.  
  275.     tempStr := NumberToHex(paramPtr, theSysRec.systemVersion, 3);{ now the system version }
  276.     for tempInt := 1 to 3 do
  277.       theResult := concat(theResult, tempstr[tempInt], '.');
  278.     theResult[length(theResult)] := ',';{ kill trailing period }
  279.  
  280.     case theSysRec.processor of    { and the processor }
  281.       0: 
  282.         tempstr := 'CPU Unknown,';
  283.       1: 
  284.         tempstr := 'Motorola 68000,';
  285.       2: 
  286.         tempstr := 'Motorola 68010,';
  287.       3: 
  288.         tempstr := 'Motorola 68020,';
  289.       4: 
  290.         tempstr := 'Motorola 68030,';
  291.       5: 
  292.         tempstr := 'Motorola 68030,';
  293.       6: 
  294.         tempstr := 'Motorola 68040,';
  295.       otherwise
  296.         tempstr := concat('unknown CPU #', NumberToString(paramPtr, theSysRec.processor), ', ');
  297.     end;
  298.     theResult := concat(theResult, tempstr);
  299.  
  300.     if theSysRec.hasFPU then          { do we have a coprocessor? }
  301.       tempstr := 'FPU,'
  302.     else
  303.       tempstr := 'no FPU,';
  304.     theResult := concat(theResult, tempstr);
  305.  
  306.     if theSysRec.hasColorQD then      { do we have color QD? }
  307.       tempstr := 'Color Quick Draw,'
  308.     else
  309.       tempstr := 'No Color Quick Draw,';
  310.     theResult := concat(theResult, tempstr);
  311.  
  312.     case theSysRec.keyBoardType of    { what keyboard was this typed on? }
  313.       0: 
  314.         tempstr := 'Macintosh Plus keyboard with keypad,';
  315.       1: 
  316.         tempstr := 'Macintosh keyboard,';
  317.       2: 
  318.         tempstr := 'Macintosh keyboard and keypad,';
  319.       3: 
  320.         tempstr := 'Macintosh Plus keyboard,';
  321.       4: 
  322.         tempstr := 'Apple Extended keyboard,';
  323.       5: 
  324.         tempstr := 'Standard ADB keyboard,';
  325.       6: 
  326.         tempstr := 'Portable Keyboard,';
  327.       7: 
  328.         tempstr := 'Portable Keyboard (ISO),';
  329.       8: 
  330.         tempstr := 'Apple Standard Keyboard (ISO),';
  331.       9: 
  332.         tempstr := 'Apple Extended Keyboard (ISO),';
  333.       otherwise
  334.         tempstr := concat('UnknownKbd  #', NumberToString(paramPtr, theSysRec.keyBoardType), ', ');
  335.     end;
  336.     theResult := concat(theResult, tempstr);
  337.  
  338.     tempstr := NumberToString(paramPtr, theSysRec.atDrvrVersNum);  { appletalk present? }
  339.     if tempStr = '0' then
  340.       theResult := concat(theResult, 'AppleTalk not connected,')
  341.     else
  342.       theResult := concat(theResult, 'AppleTalk version (', tempstr, ')', ',');
  343.  
  344.     tempstr := NumberToString(paramPtr, theSysRec.sysVRefNum);    { system folder wd ref num }
  345.     theResult := concat(theResult, 'System Folder wdRefNum (', tempstr, ')');
  346.  
  347.     paramPtr^.returnValue := PasToZero(paramPtr, theResult);        { all done, send in the results }
  348.   end;
  349.  
  350.   procedure main;
  351.   begin
  352.     sysEnv(paramPtr);
  353.   end;
  354. end.